# -*- coding: utf-8 -*-
'''
@author: olivia.dou
Created on: 2019/11/14 15:20
desc: 用于调试代码，可指定运行特定文件的特定函数
1. 修改glo.set_value("config_name", XXX)为正确的配置
2. 导入需要运行的函数
'''
import logging,sys
import base.globalvars as glo
glo.init()
glo.set_value("config_name", "DAS_dev")
from urllib.parse import urlparse
from base.get_config import get_url_dict,get_log_level
from proj_spec.DAS.model import *
from proj_spec.DAS.task import *


def set_logging():

    #logging.basicConfig(level=eval("logging." + get_log_level())
    logging.basicConfig(stream=sys.stdout, level=eval("logging." + get_log_level())
                        # , format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                        # datefmt='%a, %d %b %Y %H:%M:%S'
                        )
    logging.getLogger("urllib3").setLevel(logging.WARNING)

    # # 输出到结果报告文件的同时，在控制台打印日志
    # ch = logging.StreamHandler()
    # formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
    # ch.setFormatter(formatter)
    # logging.getLogger('').addHandler(ch)

set_logging()
url_dict = get_url_dict()
if url_dict != {}:
    for item in url_dict.items():
        glo.set_value(item[0], item[1])
        glo.set_value("host" + item[0][-1], urlparse(item[1]).hostname)

#get_model_info("none")
